#ifndef SCOPED_PTR_H
#define SCOPED_PTR_H

#include <cstdlib>  /// For NULL declaration

/**
 * \namespace bga
 * \brief API namespace
 */
namespace bga
{

/**
 * This class define a smart pointer. Only one instance of a pointer will be used with this pointer. When this
 * pointer will be destroyed, the contained pointer will be deleted.
 */
template <typename T>
class Scoped_Ptr
{
	public:
        /**
         * Constructor
         * \param pPtr : pointer to embedd
         */
		Scoped_Ptr(T* pPtr = NULL);

		/**
		 * Destructor
		 */
		virtual ~Scoped_Ptr();

        /**
         * \brief reset the pointer
         * \param pPtr : new value of the pointer.
         *
         * This function will reset the pointer. To do that, it will delete the current pointer before set the new value.
         */
		void reset(T* pPtr = NULL);

        /**
         * \brief get the embadded pointer
         * \return the embadded pointer
         */
		T* get() const;

		/**
		 * \brief operator needed to access member of a complex pointer(object or structure)
		 * \return the embadded pointer
		 */
		T* operator->() const;

		/**
		 * \brief operator needed to dereference pointer
		 * \return the object macthing to the embadded pointer
		 */
		T& operator*() const;

		/**
		 * \brief operator needed to test if the ponter is NULL
		 * \return true if the pointer is NUll, false if not
		 */
		bool operator!() const;


	protected:

	private:
        T* ptr;    ///<! Embedded Pointer
};

}

#include "Scoped_Ptr.inl"

#endif // SCOPED_PTR_H

